<?php
//header("Location: http://localhost/web/app/test_getjson.html"); 


error_reporting(0);
 session_start();
 //数据库连接
 $conn=mysql_connect('localhost','root','root');
 mysql_select_db('itxmgl',$conn);
 //定义常量
 define(ALL_PS,"PHP");
  mysql_query("set names 'utf8'"); 

  $jsonData= json_encode($_POST); 
    $objData=json_decode($jsonData);
    $keyword=$objData->{'keyword'}; 

  if($keyword!=""){
  $sql = "SELECT * FROM r_commodity WHERE Kind like '%$keyword%' or Course_Name like '%$keyword%'";}
  $res=mysql_query($sql);
 while($row=mysql_fetch_array($res)){
   
   $arrayobject = new ArrayObject($row);
     $array[] =  $arrayobject;
}

$tempArr = array('objectArray'=>$array);
$backData = json_encode($tempArr); 
echo $backData; 
// echo true;
  

 ?>